<template>
  <div class="seat-container">
    <div class="seat-svg" v-html="venueSvg"></div>
  </div>
</template>

<script setup>
import { fetchTourSiteVenueDetail } from '@/api/index.js'
import { ref, watch, onMounted, computed } from 'vue'
import { useStore } from '@/stores/index.js'
const store = useStore()

const sessionId = computed(() => store.purchaseInformation.sessionId)
const venueSvg = ref(null)

onMounted(() => {
  getTourSiteVenueDetail(sessionId.value)
})

const getTourSiteVenueDetail = async (sessionId) => {
  try {
    const { statusCode, data } = await fetchTourSiteVenueDetail(sessionId)

    if (statusCode === 200) {
      console.log('演出场地图获取成功', data)
      venueSvg.value = data.svg
    }
  } catch (error) {
    console.log('演出场地图获取失败', error)
  }
}
</script>

<style scoped lang="scss">
.seat-container {
  width: 100%;
  overflow: hidden;

  .seat-svg {
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: center;

    // 确保 SVG 响应式显示
    :deep(svg) {
      width: 100%;
      height: auto;
      max-width: 100%;
      display: block;
      // 允许用户交互（如果需要拖动）
      touch-action: manipulation;
      user-select: none;
    }
  }
}
</style>
